import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { HandworkCommissionVO, HandworkCommissionForm, HandworkCommissionQuery } from '@/api/commission/handworkCommission/types';

/**
 * 查询手工佣金列表
 * @param query
 * @returns {*}
 */

export const listHandworkCommission = (query?: HandworkCommissionQuery): AxiosPromise<HandworkCommissionVO[]> => {
  return request({
    url: '/commission/handworkCommission/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询手工佣金详细
 * @param id
 */
export const getHandworkCommission = (id: string | number): AxiosPromise<HandworkCommissionVO> => {
  return request({
    url: '/commission/handworkCommission/' + id,
    method: 'get'
  });
};

/**
 * 新增手工佣金
 * @param data
 */
export const addHandworkCommission = (data: HandworkCommissionForm) => {
  return request({
    url: '/commission/handworkCommission',
    method: 'post',
    data: data
  });
};

/**
 * 修改手工佣金
 * @param data
 */
export const updateHandworkCommission = (data: HandworkCommissionForm) => {
  return request({
    url: '/commission/handworkCommission',
    method: 'put',
    data: data
  });
};

/**
 * 删除手工佣金
 * @param id
 */
export const delHandworkCommission = (id: string | number | Array<string | number>) => {
  return request({
    url: '/commission/handworkCommission/' + id,
    method: 'delete'
  });
};
